/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.risk.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 *
 * @author IT-Mafia
 */
@Entity
@Table(name = "rbh_risk_person_impacted")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
@XmlRootElement
public class PersonImpacted implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "PERSON_IMPACTED_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short personImpactedId;
    @Basic(optional = false)
    @Column(name = "PERSON_IMPACTED_NAME", unique = true, nullable = false, length = 100)
    private String personImpactedName;
    @Basic(optional = false)
    @Column(name = "PERSON_IMPACTED_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short personImpactedOrderNumber;
    @Basic(optional = false)
    @Column(name = "PERSON_IMPACTED_STATUS", columnDefinition = "boolean default true", nullable = false)
    private boolean personImpactedStatus;
    @ManyToMany(mappedBy = "personImpactedList", fetch = FetchType.LAZY)
    private List<RiskData> riskDataList;

    public PersonImpacted() {
    }

    public PersonImpacted(Short personImpactedId) {
        this.personImpactedId = personImpactedId;
    }

    public PersonImpacted(Short personImpactedId, String personImpactedName, short personImpactedOrderNumber, boolean personImpactedStatus) {
        this.personImpactedId = personImpactedId;
        this.personImpactedName = personImpactedName;
        this.personImpactedOrderNumber = personImpactedOrderNumber;
        this.personImpactedStatus = personImpactedStatus;
    }

    public Short getPersonImpactedId() {
        return personImpactedId;
    }

    public void setPersonImpactedId(Short personImpactedId) {
        this.personImpactedId = personImpactedId;
    }

    public String getPersonImpactedName() {
        return personImpactedName;
    }

    public void setPersonImpactedName(String personImpactedName) {
        this.personImpactedName = personImpactedName;
    }

    public short getPersonImpactedOrderNumber() {
        return personImpactedOrderNumber;
    }

    public void setPersonImpactedOrderNumber(short personImpactedOrderNumber) {
        this.personImpactedOrderNumber = personImpactedOrderNumber;
    }

    public boolean isPersonImpactedStatus() {
        return personImpactedStatus;
    }

    public void setPersonImpactedStatus(boolean personImpactedStatus) {
        this.personImpactedStatus = personImpactedStatus;
    }

    @XmlTransient
    public List<RiskData> getRiskDataList() {
        return riskDataList;
    }

    public void setRiskDataList(List<RiskData> riskDataList) {
        this.riskDataList = riskDataList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (personImpactedId != null ? personImpactedId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PersonImpacted)) {
            return false;
        }
        PersonImpacted other = (PersonImpacted) object;
        if ((this.personImpactedId == null && other.personImpactedId != null) || (this.personImpactedId != null && !this.personImpactedId.equals(other.personImpactedId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return personImpactedName;
    }
}